/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.uefs.cedoc.controle.fundo;

import br.uefs.cedoc.controle.Command;
import br.uefs.cedoc.controle.CommandException;
import br.uefs.cedoc.db.exception.DBConnectionException;
import br.uefs.cedoc.db.fundo.DBFundo;
import br.uefs.cedoc.entidades.FundoBean;
import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author suporte
 */
public class UpdateFundoCommand implements Command {
	  private String next;

	  public UpdateFundoCommand(String next) {
	    this.next = next;
	  }

    public String execute(HttpServletRequest req) throws CommandException {
        try {
            
            DBFundo dbfundo = new DBFundo();
            FundoBean fundo = new FundoBean();
            fundo.setIdFundo(Integer.parseInt(req.getParameter("id")));
            fundo.setFonte(req.getParameter("fonte"));
            //System.out.println("Ob fundo Id= "+fundo.getIdFundo()+" SEC= "+fundo.getFonte());
            dbfundo.editarFundo(fundo);
            req.setAttribute("status.msg", "Fundo atualizado1d!");
            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (DBConnectionException ex) {
                ex.printStackTrace();
            }
           
            
            return next;

    }



	}
